//
//  ZJMeHeadView.m
//  ZiJinLian
//
//  Created by lc on 2017/3/23.
//  Copyright © 2017年 lzy. All rights reserved.
//

#import "ZJMeHeadView.h"

@implementation ZJMeHeadView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame{
    if (self==[super initWithFrame:frame ]) {
        UIView* cutline1=[ZJUITools getHCutLine];
        UIView* cutline2=[ZJUITools getHCutLine];
        UIView* cutline3=[ZJUITools getHCutLine];
        UIView* cutline4=[ZJUITools getHCutLine];
        UIView* cutline5=[ZJUITools getHCutLine];
        UIView* cutline6=[ZJUITools getCutLine];
        cutline1.backgroundColor=RGB(229, 229, 229);
        cutline2.backgroundColor=RGB(229, 229, 229);
        cutline3.backgroundColor=RGB(229, 229, 229);
        cutline4.backgroundColor=RGB(229, 229, 229);
        cutline5.backgroundColor=RGB(229, 229, 229);
        
        [self addSubview:self.bgImage];
        [self addSubview:self.commItem];
        [self addSubview:self.waitPayBtn];
        [self addSubview:self.waitSend];
        [self addSubview:self.waitRev];
        [self addSubview:self.waitQuit];
        
        [self addSubview:cutline4];
        [self addSubview:cutline5];
        [self addSubview:cutline1];
        [self addSubview:cutline2];
        [self addSubview:cutline3];
        [self addSubview:cutline6];
        
        
        [self addSubview:self.headImg];
        [self addSubview:self.headView];
        [_headView setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _headView.titleLabel.textAlignment=NSTextAlignmentCenter;
        _headView.titleLabel.font=FontAndStyle14;
    
        
        UILabel* lab =[ZJUITools getLab_S14_C6];
        lab.text=MyString(@"查看全部订单");
        UIButton*btn=[[UIButton alloc]init];
        [btn addTarget:self action:@selector(allBtnClick) forControlEvents:UIControlEventTouchUpInside];
        _commItem.btn.tag=5;
        [_commItem mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(50);
            make.width.mas_equalTo(self.mas_width);
            make.top.equalTo(_bgImage.mas_bottom);
            make.left.equalTo(self.mas_left);

        }];

		
        [_commItem addSubview:btn];
        [_commItem addSubview:lab];
       
        [_bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_top);
            make.left.equalTo(self.mas_left);
            make.height.mas_equalTo(180);
            make.width.mas_equalTo(MainW);
        }];

		
        [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(_bgImage.mas_centerX);
            make.centerY.equalTo(_bgImage.mas_centerY);
            make.height.mas_equalTo(80);
            make.width.mas_equalTo(80);
        }];

		
        [_headImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(_headView.mas_centerX);
            make.centerY.equalTo(_headView.mas_centerY);
            make.height.mas_equalTo(50);
            make.width.mas_equalTo(50);
        }];

        

       [lab mas_makeConstraints:^(MASConstraintMaker *make) {
           make.centerY.equalTo(_commItem.mas_centerY);
           make.right.equalTo(_commItem.arrow.mas_left).offset(-5);
       }];
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(50);
            make.width.mas_equalTo(self.mas_width);
            make.top.equalTo(_bgImage.mas_bottom);
            make.left.equalTo(self.mas_left);;
        }];
        
        [_waitPayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(0);
            make.top.equalTo(_commItem.mas_bottom);
            make.width.mas_equalTo(MainW/4);
            make.height.mas_equalTo(MainW/4-10);
        }];
        [cutline1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(MainW/4);
            make.centerY.equalTo(_waitPayBtn.mas_centerY);
            make.height.mas_equalTo(30);
            make.width.equalTo(0.5);
         }];
        [cutline2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(MainW/4*2);
            make.centerY.equalTo(_waitPayBtn.mas_centerY);
            make.height.mas_equalTo(30);
             make.width.equalTo(0.5);
        }];
        [cutline3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(MainW/4*3);
            make.centerY.equalTo(_waitPayBtn.mas_centerY);
            make.height.mas_equalTo(30);
             make.width.equalTo(0.5);
        }];
        
        [cutline5 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(10);
            make.height.equalTo(0.5);
            make.width.equalTo(MainW-20);
            make.top.equalTo(230);
        }];

        [_waitSend mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(MainW/4.0);
            make.centerY.equalTo(_waitPayBtn.mas_centerY);
            make.width.mas_equalTo(MainW/4);
            make.height.mas_equalTo(MainW/4-10);
        }];
        
        [_waitRev mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(MainW/4.0*2);
            make.centerY.equalTo(_waitPayBtn.mas_centerY);
            make.width.mas_equalTo(MainW/4);
            make.height.mas_equalTo(MainW/4-10);
        }];
        [_waitQuit mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(MainW/4.0*3);
            make.centerY.equalTo(_waitPayBtn.mas_centerY);
            make.width.mas_equalTo(MainW/4);
            make.height.mas_equalTo(MainW/4-10);
        }];
        [cutline4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_waitPayBtn.mas_bottom);
            make.left.equalTo(self.mas_left);
            make.height.equalTo(0.5);
            make.width.equalTo(MainW);
        }];
        [cutline6 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(MainW);
            make.height.equalTo(10);
            make.left.equalTo(self.mas_left);
            make.top.equalTo(cutline4.mas_bottom);
        }];
        
    
    }
    return self;
}



-(UIImageView *)bgImage{

    if (_bgImage == nil) {
        _bgImage=[ZJUITools getImage:@"me_nav_bg"];
    }
    return _bgImage;
}
-(UIImageView *)headImg{
    if (_headImg == nil) {
        _headImg=[ZJUITools getImage:@"img_head_nor"];
    }
    return _headImg;
}
-(ZJUIButton *)headView{
    if (!_headView) {
        _headView=[[ZJUIButton alloc]init];
        [_headView addTarget:self action:@selector(headclick) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _headView;
}

-(ZJCommWithImageItem *)commItem{
    if (!_commItem) {
        _commItem=[[[ZJCommWithImageItem alloc]init]zjCommItemInitWithTitle:MyString(@"我的订单") image:@"icon_order"];
    }
    return  _commItem;
}

-(ZJTipsBtn *)waitPayBtn{
    if (!_waitPayBtn) {
        _waitPayBtn= [[ZJTipsBtn alloc]initWithZJTipsBtn:MyString(@"待付款") image:@"icon_payment"];
        _waitPayBtn.tag=1;
        [_waitPayBtn addTarget:self action:@selector(payBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _waitPayBtn;
}
-(ZJTipsBtn *)waitSend{
    if (!_waitSend) {
        _waitSend=[[ZJTipsBtn alloc]initWithZJTipsBtn:MyString(@"待发货") image:@"icon_shipping"];
        _waitSend.tag=2;
        [_waitSend addTarget:self action:@selector(payBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _waitSend;
}

-(ZJTipsBtn *)waitRev{
    if (!_waitRev) {
        _waitRev=[[ZJTipsBtn alloc]initWithZJTipsBtn:MyString(@"待收货") image:@"icon_receive"];
        _waitRev.tag=3;
        [_waitRev addTarget:self action:@selector(payBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _waitRev;
}
-(ZJTipsBtn *)waitQuit{
    if (!_waitQuit) {
        _waitQuit=[[ZJTipsBtn alloc]initWithZJTipsBtn:MyString(@"售后") image:@"icon_change"];
        _waitQuit.tag=4;
        [_waitQuit addTarget:self action:@selector(payBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _waitQuit;
   
}
-(void)headclick{
    if ([_delegate respondsToSelector:@selector(headClickOption)]) {
        [_delegate headClickOption];
    }
}
-(void)payBtnClick:(ZJTipsBtn*)sender{
    [_delegate obligationClick:sender];
}
-(void)allBtnClick{
    [_delegate allorderClick];
}
@end
